Skip to content

fixed favouriting feature with new packet structure#249

Merged
alexwhelan12 merged 6 commits intomainfrom
TEL-293-Fix-favourites-feature
Jan 31, 2026
Merged

fixed favouriting feature with new packet structure#249
alexwhelan12 merged 6 commits intomainfrom
TEL-293-Fix-favourites-feature

Conversation

@alexwhelan12
Copy link
Contributor

@alexwhelan12 alexwhelan12 commented Jun 30, 2025

Summary by CodeRabbit

  • Chores

    • Added dependency support for Apple Silicon (Darwin ARM64) architecture
  • New Features

    • Expanded favorites to include energy management system data
    • Improved formatting and display of favorite item labels
    • Extended favorites functionality to support all field types

✏️ Tip: You can customize this high-level summary in your review settings.

@alexwhelan12 alexwhelan12 requested a review from a team as a code owner June 30, 2025 03:23
@vercel
Copy link

vercel bot commented Jun 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
helios-telemetry Ready Ready Preview, Comment Jan 15, 2026 3:53am

Copy link
Member

@promatty promatty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the values in the favourites bar dont match what is displayed in the tabs

add.to.favs.mov

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This pull request refactors favorite item tracking across PIS data components by introducing hierarchical path tracking through nested component trees, removing explicit fault flags from data definitions, and reworking the favorite lookup table logic to support array-based field extraction alongside recursive object traversal. A new dependency is also added.

Changes

Cohort / File(s) Summary
Dependency Addition
package.json
Added @next/swc-darwin-arm64 v15.3.4 to dependencies for platform-specific build support.
Favorite Label Formatting
packages/client/src/components/containers/BottomInformationContainer.tsx
Integrated mbms into data flow; introduced formatPathLabel helper to prettify camelCase and PascalCase path strings before rendering favorite items.
Path Tracking Architecture
packages/client/src/components/transformers/PISTransformer.tsx
Extended path tracking through component hierarchy with new props: path in PISTransformer, basePath in FieldsPrinter, fieldPath in FieldPrinter. Removed conditional rendering guard (field.isFault) for Add to Favourites button, now unconditionally displayed.
Fault Data Structure Simplification
packages/client/src/hooks/PIS/PIS.battery.tsx, packages/client/src/hooks/PIS/PIS.faults.tsx
Removed isFault: true flags from all fault and warning entries across BatteryFaults, ContactorFaults, MBMS, and MotorFaults data structures.
Favorite Lookup Logic Refactor
packages/client/src/hooks/favouriteLookupTable.ts
Replaced monolithic flattening approach with dual-path traversal: early-exit for I_PISField arrays, recursive object traversal for nested properties. Added extractFields helper and imported I_PISField type for typed field array handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PISTransformer as PISTransformer<br/>(path=[])
    participant FieldsPrinter as FieldsPrinter<br/>(basePath)
    participant FieldPrinter as FieldPrinter<br/>(fieldPath)
    participant useFavLookup as useFavouriteLookupTable
    participant Favorites as Favorite Storage

    User->>PISTransformer: Render PIS data with path
    PISTransformer->>FieldsPrinter: Pass basePath=key (for arrays)
    FieldsPrinter->>FieldPrinter: Propagate fieldPath=`${basePath}.${field.name}`
    FieldPrinter->>useFavLookup: Query favorite using fieldPath
    useFavLookup->>useFavLookup: extractFields: Traverse to leaf values
    useFavLookup-->>FieldPrinter: Return formatted favorite label
    FieldPrinter->>FieldPrinter: Display with formatPathLabel
    FieldPrinter->>Favorites: Add/Remove favorite on user action
    Favorites-->>FieldPrinter: Confirm favorite toggled
    User-->>User: See updated favorite status
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Paths now wind through nested trees,
Each field tracked with ease,
Faults unadorned, favorites soar,
Lookup tables do more—
Prettified labels make all agree! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fixed favouriting feature with new packet structure' directly describes the main changes across the pull request: fixing the favourites functionality and adapting it to work with the restructured PIS data (removing isFault flags, adding path tracking, updating lookup table logic).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@package.json`:
- Line 23: Remove the platform-specific SWC package entry
"@next/swc-darwin-arm64": "15.3.4" from package.json (do not replace it with
another platform-specific package); after removing, run your package manager
install (yarn/npm) to update the lockfile and ensure Next.js installs the
correct platform SWC binary automatically, and commit the updated package.json
and lockfile changes.
🧹 Nitpick comments (3)
packages/client/src/hooks/favouriteLookupTable.ts (1)

15-21: Add guard for empty arrays in I_PISField detection.

The duck-typing check examines only node[0] to determine if the array contains I_PISField objects. While node.length guards against empty arrays, consider explicitly handling arrays with mixed types or non-I_PISField contents more defensively.

Optional: Add runtime type guard
      if (
        Array.isArray(node) &&
        node.length &&
        typeof node[0] === "object" &&
+       node[0] !== null &&
        "name" in node[0] &&
        "data" in node[0]
      ) {
packages/client/src/components/containers/BottomInformationContainer.tsx (2)

18-29: Simplify callback dependency array.

currentAppState is listed as a dependency but isn't directly used in the callback body—only favourites and setCurrentAppState are referenced. This can cause unnecessary callback recreation when unrelated app state changes.

Suggested fix
     },
-    [currentAppState, favourites],
+    [favourites, setCurrentAppState],
   );

31-41: Consider extracting shared formatting logic.

This formatPathLabel function applies the same regex transformations as formatKey in PISTransformer.tsx (lines 189-194). Consider extracting this into a shared utility to avoid duplication.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1db2406 and 8d962e8.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • package.json
  • packages/client/src/components/containers/BottomInformationContainer.tsx
  • packages/client/src/components/transformers/PISTransformer.tsx
  • packages/client/src/hooks/PIS/PIS.battery.tsx
  • packages/client/src/hooks/PIS/PIS.faults.tsx
  • packages/client/src/hooks/favouriteLookupTable.ts
💤 Files with no reviewable changes (2)
  • packages/client/src/hooks/PIS/PIS.battery.tsx
  • packages/client/src/hooks/PIS/PIS.faults.tsx
🧰 Additional context used
🧬 Code graph analysis (3)
packages/client/src/components/containers/BottomInformationContainer.tsx (1)
packages/client/src/hooks/PIS/PIS.mbms.tsx (1)
  • I_PIS (6-529)
packages/client/src/hooks/favouriteLookupTable.ts (2)
packages/client/src/objects/PIS/PIS.interface.ts (1)
  • I_PISField (44-44)
packages/shared/src/functions.ts (1)
  • flattenObject (487-510)
packages/client/src/components/transformers/PISTransformer.tsx (1)
packages/client/src/contexts/AppStateContext.tsx (1)
  • useAppState (229-231)
🔇 Additional comments (5)
packages/client/src/hooks/favouriteLookupTable.ts (1)

22-31: LGTM!

The field iteration correctly captures each field in its own closure scope, handles missing data with optional chaining, and the boolean-to-string conversion is consistent with the display logic in RangeCheckedFieldData.

packages/client/src/components/containers/BottomInformationContainer.tsx (1)

10-14: LGTM!

Adding mbms to the data array properly extends favourite tracking to MBMS-related fields, supporting the new packet structure.

packages/client/src/components/transformers/PISTransformer.tsx (3)

89-115: LGTM on path-based favourites tracking!

The fieldPath prop correctly enables hierarchical field identification for favourites. The callback properly uses fieldPath and the dependency array is accurate.


147-178: Path propagation looks correct.

FieldsPrinter correctly constructs fieldPath from basePath and field.name, maintaining consistency with the lookup table's path format.


180-227: Path tracking through recursive traversal is well-implemented.

The path array correctly accumulates keys during traversal, and newPath.join(".") produces paths that match the lookup table format. The recursive call to PISTransformer preserves path context for nested structures.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@burtonjong
Copy link
Member

@alexwhelan12 The green button is calling your name

@alexwhelan12 alexwhelan12 merged commit 7729d11 into main Jan 31, 2026
8 checks passed
@alexwhelan12 alexwhelan12 deleted the TEL-293-Fix-favourites-feature branch January 31, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants